package com.spzx.product.api;

import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.product.api.domain.dto.ProductInfoDto;
import com.spzx.product.api.domain.dto.ProductSkuDto;
import com.spzx.product.api.domain.param.SkuQuery;
import com.spzx.product.api.factory.RemoteProductSkuFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 商品sku
 *
 * @author gaozz
 */
@FeignClient(contextId = "remoteProductSkuService",
        value = ServiceNameConstants.PRODUCT_SERVICE,
        fallbackFactory = RemoteProductSkuFallbackFactory.class)
public interface RemoteProductSkuService {

    /**
     * 获取畅销商品列表
     *
     * @param source
     * @return
     */
    @GetMapping(value = "/productSku/findProductSkuNo20")
    R<List<ProductSkuDto>> findProductSkuNo20(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取商品列表
     *
     * @param pageNum
     * @param pageSize
     * @param query
     * @param source
     * @return
     */
    @GetMapping("/productSku/skuList/{pageNum}/{pageSize}")
    R<List<ProductSkuDto>> skuList(@PathVariable("pageNum") Integer pageNum,
                                   @PathVariable("pageSize") Integer pageSize,
                                   @SpringQueryMap SkuQuery query,
                                   @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据skuId查询商品详情信息
     *
     * @param skuId
     * @param source
     * @return
     */
    @GetMapping("/productSku/item/{skuId}")
    R<ProductInfoDto> getProductInfoBySkuId(@PathVariable("skuId") Long skuId,
                                            @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据skuId查询商品sku信息
     *
     * @param skuId
     * @return
     */
    @GetMapping("/productSku/sku/{skuId}")
    R<ProductSkuDto> getSkuInfoBySkuId(@PathVariable("skuId") Long skuId,
                                       @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据skuId集合查询商品sku的价格
     *
     * @param skuIds
     * @return
     */
    @PostMapping("/productSku/getSkuPrice")
    R<Map<Long, BigDecimal>> getSkuPrice(@RequestBody Set<String> skuIds,
                                         @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
